function [aa,bb]=msdtoab_dynare(bayestopt_); 
% ================================================================= 
% Modified version of MSD2AB to get the ALPHA and BETA 
% location parameters from bayestopt_ 
% Since this is used to generate starting values only and not for
% computation, we ignore the (possible) bounds on the BETA and GAMMA 
% 
% 
% PSHAPE        == 1 Beta 
%               == 2 Gamma 
%               == 3 Normal 
%               == 4 IG1 
%               == 5 U 
%               == 6 IG2 
% 
% .P1 and .P2 should equal V and S in my notation for the IG1 
%  Check !!
% For the IG1 and IG2 A  is v i.e. deg of freedom 
%                     B  is s i.e. scale parameter 
% Alejandro Justiniano August 27 2008 
% =============================================================
np=length(bayestopt_.pshape); 
aa=zeros(np,1); 
bb=zeros(np,1); 
for ii=1:np;
    MU=bayestopt_.pmean(ii);
    SD=bayestopt_.pstdev(ii);
    switch bayestopt_.pshape(ii); 
        case  1 % Beta  
            bt=MU*( (1-MU)^2 )/(SD^2) - ( 1 - MU );
            alp=MU*bt/(1-MU);
        case 2  % Gamma 
            bt=(SD^2)/MU;
            alp=MU/bt;
        case 3  % Normal 
            bt=SD; 
            alp=MU; 
        case 4 % IG1 
            % BT  is S 
            % ALP is V degrees of freedom 
            [bt,alp]=inverse_gamma_specification( MU , SD ,1 );
            if abs( bt-bayestopt_.p1(ii) ) > 1e-5; error('Did not match transformation of IG1');end 
            if abs( alp-bayestopt_.p2(ii) ) > 1e-5; error('Did not match transformation of IG1');end
        case 5 % Uniform 
            if ~isempty(MU);error('MU should be empty');end
            if ~isempty(SD);error('SD should be empty');end
            %[mu,sd,mux,sdx,x]=u_ab2msd(a,b,t);
%             alp=bayestopt_.p3(ii); 
%             alp=bayestopt_.p4(ii);          
            alp=bayestopt_.lb(ii); 
            bet=bayestopt_.ub(ii); 
        case 6  
            if isinf(SD);
                alp=4
            else
                alp=2*(MU^2)/(SD^2) + 4;
            end
            bt=MU*(alp-2);
    end             
            
    aa(ii)=alp;
    bb(ii)=bt;
end;